<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="managesystem.Student" %>
<%@ page import="controlsystem.StatisticsController" %>
<%@ page import="controlsystem.Course" %>

	 <%
	 	Student currStud = (Student) session.getAttribute("currStud");
	 %>

	<!-- dive= De naam van de div waarin de grafiek geplaatst wordt 
	k= nummer van de div -->
	<%
		String pageID = request.getParameter("dive");
			
		int k=1;
	    if (request.getParameter("dive").equals("chart_div2")){
	    	k=2;       	
	    }
	    else if (request.getParameter("dive").equals("chart_div3")){
	    	k=3;       	
	    }
	    else if (request.getParameter("dive").equals("chart_div4")){
	    	k=4;  
	    }
	%>
    
    <!-- hashmap om graf te vullen -->    
    
	<%
     HashMap<Course,Double> hoursPerCourse = StatisticsController.getTimePerCourse(currStud);
    %>
    	  
   <div id="top">
  
  <div class="title" id="<%="title"+k%>">
  Hours per course
  </div>
  
  <div id="settings">
  <img src="plot2/edit.png" alt="edit" onClick="show_settings(<%=k%>);" />
  </div>
  
  </div>
  
    <div class="chart_div" id="<%=request.getParameter("dive")%>">
    </div>
  
  <!-- fullSettingsbox = de volledige settings, hetgeen ge ziet als ge op edit drukt -->
<div class="fullSettingsbox" id="<%="fullSettingsbox"+k%>">     

	    
	<form name="input" method="get">

	<!-- kiezen welk type grafiek -->
	<select class=selectType id="selectType">
		<option value='0' selected>Choose your graph</option>
    	<option value='1'>Hours per Course</option>
    	<option value='2'>Time vs Ideal</option>
<!--     	<option value='3'>Top buddies</option>
    	<option value='4'>Top places</option> -->
    	<option value='5'>Course Type Distribution</option>
    	<option value='6'>Average Rating</option>
    	<option value='7'>Days of the week</option>
    	<option value='8'>School/other activities</option>
    	<option value='9'>Other activities</option>
    	<option value='10'>Average time per Course</option>
	</select>

	</form> 
    
    <div id="<%="formTimePerCourse"+k%>">
 
    <form name="input" method="get">
    <select name="typeOfChart">
    <option value="0">Pie chart</option>
    <option value="1">Bar chart</option>
    <option value="2">Table</option>
    </select>
    </br>
                
      <%
      StatisticsController.getAvgTimePerCourse(currStud);
      Iterator it2 = hoursPerCourse.entrySet().iterator();
        	  int m = 0;
           	  while (it2.hasNext()) {
       		  Map.Entry pairs = (Map.Entry)it2.next();
      %> 
	  	  
	  <input type="checkbox" name="<%=((Course)pairs.getKey()).getName()%>" value="<%=pairs.getValue()%>" /> <%=((Course)pairs.getKey()).getName()%> </br>

	  <%
	  	m++;
	  	  }
	  %>
	
	  <INPUT TYPE="button" NAME="btnUpdate" Value="Update" onClick="updateChartTimePerCourse(this.form, '<%=request.getParameter("dive")%>',<%=k%>)">
	  </form> 
	 </div> 
	

    <div id="<%="formTimevsIdeal"+k%>">
    <form name="input" method="get">
    <select name="typeOfChart">
    <option value="0">Pie chart</option>
    <option value="1">Bar chart</option>
    </select>
    </br>

   <select name="course">   
    
            
      <%
                         	List<Course> studCourses = currStud.getCourses();
                               for(Course c : studCourses){
                         %>
    	  <option value=<%="tvid"+c.getName()%> > <%=c.getName()%> </option>
    	  <%
    	  	}
    	  %>
    	  </select>
    	  <%
    	  	for(Course c : studCourses){
    	        HashMap<Double,Double> timeVsId = StatisticsController.getTimeVsIdeal(c,currStud);
    	        Iterator it_timeid = timeVsId.entrySet().iterator();
    	        Map.Entry pairs = (Map.Entry)it_timeid.next();
    	  /*    System.out.println(pairs.getKey());
    	        System.out.println(pairs.getValue());
    	        System.out.println(c.getName()); */
    	  %>
      <input type="hidden" id="<%="tvid"+c.getName()%>" name="<%=pairs.getValue()%>" value="<%=pairs.getKey()%>" />
      
 	  <%
       	  	}
       	  %>		  
      

	  </br>
	  <INPUT TYPE="button" NAME="btnUpdate" Value="Update" onClick="updateChartTimevsIdeal(this.form, '<%=request.getParameter("dive")%>',<%=k%>)">
	  </form> 
	  
	</div>  
	
	<div id="<%="formTopBuddies"+k%>">
    <form name="input" method="get">
    <select name="typeOfChart">
    <option value="0">Pie chart</option>
    <option value="1">Bar chart</option>
    <option value="2">Table</option>
    </select>
    </br>
    	
	  <INPUT TYPE="button" NAME="btnUpdate" Value="Update" onClick="updateChartTopBuddies(this.form, '<%=request.getParameter("dive")%>',<%=k%>)">
	  </form> 
	  
	</div>

	<div id="<%="formTopPlaces"+k%>">
    	<form name="input" method="get">
    	<select name="typeOfChart">
    	<option value="0">Pie chart</option>
    	<option value="1">Bar chart</option>
    	<option value="2">Table</option>
    	</select>
    </br>
    	
	  <INPUT TYPE="button" NAME="btnUpdate" Value="Update" onClick="updateChartTopPlaces(this.form, '<%=request.getParameter("dive")%>',<%=k%>)">
	  </form> 
	  
	</div>	
	
	<div id="<%="formCourseDist"+k%>">
	<form name="input" method="get">
    <select name="typeOfChart">
    <option value="0">Pie chart</option>
    <option value="1">Bar chart</option>
    </select>
    </br>
    
    <select name="course">   
    
    
    <%
               	List<Course> studCourses2 = currStud.getCourses();
                   for(Course c : studCourses2){
               %>
  	  <option value=<%="coDi"+c.getName()%> > <%=c.getName()%> </option>
  	  <%
  	  	}
  	  %>
  	  </select>
  	  <%
  	  	for(Course c : studCourses){
  	      HashMap<String,Double> distribCourse = StatisticsController.getDistribution(c,currStud);
  	  %>
    <input type="hidden" name="<%="coDi"+c.getName()%>" id="<%="hoorcol"+c.getName()%>" value="<%=distribCourse.get("lesson")%>"  />
    <input type="hidden" name="<%="coDi"+c.getName()%>" id="<%="oefenz"+c.getName()%>" value="<%=distribCourse.get("exercise")%>"  />
    <input type="hidden" name="<%="coDi"+c.getName()%>" id="<%="studie"+c.getName()%>" value="<%=distribCourse.get("self")%>"  />
	<%
    }	  
    %>		  
    
    </br>
	  <INPUT TYPE="button" NAME="btnUpdate" Value="Update" onClick="updateCourseDist(this.form, '<%=request.getParameter("dive")%>',<%=k%>)">
	  </form> 
	</div>	
	
	

	<div id="<%="formAvgRating"+k%>">
    <form name="input" method="get">
    <select name="typeOfChart">
    <option value="1">Bar chart</option>
    <option value="2">Table</option>
    </select>
    </br>
    	
	  <INPUT TYPE="button" NAME="btnUpdate" Value="Update" onClick="updateChartAvgRating(this.form, '<%=request.getParameter("dive")%>',<%=k%>)">
	  </form> 
	</div>  
	
	<div id="<%="formDayOfWeek"+k%>">
    <form name="input" method="get">
    <select name="typeOfChart">
    <option value="0">Pie chart</option>
    <option value="1">Bar chart</option>
    <option value="2">Table</option>
    </select>
    </br>
    	
	  <INPUT TYPE="button" NAME="btnUpdate" Value="Update" onClick="updateChartDaysOfWeek(this.form, '<%=request.getParameter("dive")%>',<%=k%>)">
	  </form> 
	</div>  
	
	<div id="<%="formSchoolOther"+k%>">
    <form name="input" method="get">
    <select name="typeOfChart">
    <option value="0">Pie chart</option>
    <option value="1">Bar chart</option>
    <option value="2">Table</option>
    </select>
    </br>
    	
	  <INPUT TYPE="button" NAME="btnUpdate" Value="Update" onClick="updateSchoolOther(this.form, '<%=request.getParameter("dive")%>',<%=k%>)">
	  </form> 
	</div> 
	
	<div id="<%="formOther"+k%>">
    <form name="input" method="get">
    <select name="typeOfChart">
    <option value="0">Pie chart</option>
    <option value="1">Bar chart</option>
    <option value="2">Table</option>
    </select>
    </br>
    	
	  <INPUT TYPE="button" NAME="btnUpdate" Value="Update" onClick="updateOther(this.form, '<%=request.getParameter("dive")%>',<%=k%>)">
	  </form> 
	</div> 
	
		<div id="<%="avgTimePerCourse"+k%>">
    <form name="input" method="get">
    <select name="typeOfChart">
    <option value="1">Bar chart</option>
    <option value="2">Table</option>
    </select>
    </br>
    	
	  <INPUT TYPE="button" NAME="btnUpdate" Value="Update" onClick="updateAvgTimePerCourse(this.form, '<%=request.getParameter("dive")%>',<%=k%>)">
	  </form> 
	</div> 
	
</div>